package demo4;

//创建一个父类Animal
class Animal{
    private String name;
    private int age;
    //父类的构造方法
    public Animal(){

    }

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    protected void eat(){
        System.out.println("该生物正在进食");
    }

}

//创建动作接口
//跑的接口
interface run{
  public abstract   void run();
  default public void a(){
      System.out.println("run接口的default修饰方法");
  }
}
//游泳的接口
interface swming{
    public abstract void swiming();
}
//创建子类
class cat extends Animal implements run{

    @Override
    protected void eat() {
        System.out.println("吃猫粮");
    }

    @Override
    public void run() {
        System.out.println("小猫正在跑");
    }
}
class dog extends Animal implements run,swming{

    @Override
    protected void eat() {
        System.out.println("吃狗粮");
    }

    @Override
    public void run() {
        System.out.println("小狗正在跑");
    }

    @Override
    public void swiming() {
        System.out.println("修狗在游泳");
    }
}
//-----------------------------------------------------------------------
public class javaTest {
    public static void run( run inter){
        inter.run();
    }
    public static void swming( swming inter){
        inter.swiming();
    }
   /* public static void eat(Animal animal){
        Animal.super.eat();
    }*/
    public static void food(Animal animal){
        animal.eat();
    }
    public static void main(String[] args) {
        Animal cat1=new cat();
        run((run)cat1);
       // Animal.eat();
        food(cat1);
        System.out.println("------------------");
        Animal dog=new dog();
        dog.eat();
        //food(dog);
        run((run)dog);
        swming((swming)dog);
        System.out.println("-----------------");
        run run1=new dog();
        run1.a();

    }
}


